package com.itheima.dao;


import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealDao {

    /*@SelectProvider(type = Setmealprovicer.class,method = "getSql")
    @Results({
            @Result( id = true ,property = "id",column = "id"),
            @Result(property = "checkGroups",column = "id",javaType = List.class,many = @Many(select = "com.itheima.dao.SetmealDao.findById"))
    })*/
    public Page<Setmeal> SelectAllByName( String value);

    public void addSetmeal(Setmeal setmeal);

    @Select("select * from t_setmeal_checkgroup sc,t_checkgroup s where sc.setmeal_id = #{id} and s.id = sc.checkgroup_id")
    public List<CheckGroup> findById(int id);

    @Insert("insert into t_setmeal_checkgroup values(#{sid},#{gid})")
    public void addSAndG(@Param("sid") int sid,@Param("gid") int gid);

    public void updateSetmeal(Setmeal setmeal);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    public void deleteById(int id);

    @Delete("delete from t_setmeal where id = #{id}")
    public void deleteOneById(int id);

    @Delete("delete from t_order where setmeal_id = #{id}")
    void deleteOrderById(int id);

    @Select("select * from t_setmeal where id = #{id}")
    public Setmeal findOneById(int id);
}
